package com.sat.client

import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.sat.client.databinding.ActivityMainBinding
import com.sat.client.databinding.ActivityVideoBinding
import com.sat.common.base.BaseActivity
import com.sat.common.base.NoViewModel
import org.salient.artplayer.MediaPlayerManager
import org.salient.artplayer.player.SystemMediaPlayer

class VideoActivity : BaseActivity<NoViewModel, ActivityVideoBinding>() {
    override fun layoutId(): Int {
        return R.layout.activity_video
    }

    override fun initView(savedInstanceState: Bundle?) {

    }

    override fun initData() {
        intent.getStringExtra("url")?.let { url ->
            Log.e("url","------------------$url")
            mBinding?.videoView?.run {
                mediaPlayer = SystemMediaPlayer().apply {
                    setDataSource(context, Uri.parse(url))
                }

                prepare()
            }
        }
    }

    //拦截全屏时的返回事件
    override fun onBackPressed() {
        if (MediaPlayerManager.blockBackPress(this)) {
            return
        }
        super.onBackPressed()
    }

    override fun initListener() {

    }

}